package com.it.zhangjun.controller;

import com.it.zhangjun.spring.aop.BankService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * swagger测试使用
 *
 * @author: z00018123
 * @date: 2021/4/28
 **/
@RestController
@Slf4j
@RequestMapping("/swagger")
public class TestSwaggerController {

    @Autowired
    private BankService bankService;

    /**
     * 测试转账
     *
     * @param amount 转账金额
     * @return 用户信息
     */
    @GetMapping("/transfer/{amount}")
    public User test(@PathVariable("amount") int amount) {
        bankService.transfer("jordan", "kobe", amount);
        return User.builder()
                .id("1")
                .name("zhangsan")
                .sex(User.Sex.F)
                .build();
    }

    /**
     * 新增用户
     *
     * @param user 用户信息
     * @return 用户信息
     */
    @PostMapping("/save/user")
    public Result<User> save(@RequestBody User user) {
        log.info(user.toString());
        return new Result<>(user);
    }
}
